package com.tiger.cmpeb.sample1;

import javax.ejb.*;
import javax.naming.*;
import javax.rmi.*;

public class Client2 {
    public static void main(String args[]) {
        try {
            InitialContext ctx = new InitialContext();
            Object obj = ctx.lookup("comp/env/ejb/CustomerBean01");
            CustomerHome01 customerHome =
                (CustomerHome01)PortableRemoteObject.narrow(
                obj, CustomerHome01.class);
            
            Integer customerID = new Integer(1);
            Customer01 customer = customerHome.findByPrimaryKey(customerID);
            System.out.println("name = " + customer.getName());
            System.out.println("age = " + customer.getAge());
            System.out.println("age-group = " + customerHome.checkAgeGroup(customer.getAge()));
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}
